import { createRouter, createWebHashHistory, RouteRecordRaw, useRoute, useRouter } from 'vue-router';
import Layout from '@/layout/index.vue';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: 'layout'
  },
  {
    path: '/layout',
    name: 'Layout',
    component: Layout,
    redirect: '/layout/recom',
    children: [
      {
        path: 'recom',
        name: 'Recom',
        component: () => import('@/views/recom/Recom.vue')
      },
      {
        path: 'diantai',
        name: 'Diantai',
        component: () => import('@/views/diantai/Diantai.vue')
      },
      {
        path: 'video',
        name: 'Video',
        component: () => import('@/views/video/Video.vue')
      },
      {
        path: 'wode',
        name: 'Wode',
        component: () => import('@/views/wode/Wode.vue')
      }
    ]
  },
  {
    path: '/more',
    name: 'MorePlaylist',
    component: () => import('@/views/more/MorePlaylist.vue')
  },
  {
    path: '/recomdetail',
    name: 'Recomdetail',
    component: () => import('@/views/detail/Recomdetail.vue')
  },
  {
    path: '/search',
    name: 'Search',
    component: () => import('@/views/search/Search.vue')
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

export default router;

export function useMyRouters() {
  const route = useRoute();
  const router = useRouter();
  return { route, router };
}
